//
//  TwoViewController.m
//  ScrollTopAndCont
//
//  Created by xingshuai on 2020/11/5.
//

#import "TwoViewController.h"

@interface TwoViewController () <UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong) UITableView *table;


@end

@implementation TwoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3];
    
    self.table = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
    self.table.delegate = self;
    self.table.dataSource = self;
    [self.view addSubview:self.table];
    self.table.tableFooterView = [[UIView alloc]init];
}

-(void)setStr:(NSString *)str {
    _str = str;
    [self.table reloadData];
}

#pragma mark -- JXCategoryListContentViewDelegate
// 这个必须写，否则不会显示
- (UIView *)listView {
    return self.view;
}

// 模拟返回随机个数
- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    NSInteger numss = arc4random() % 6;
    numss = numss == 0 ? 2 : numss;
    
    return numss;;
}

// cell内容
- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
    
    static NSString *cellid = @"cellid";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellid];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid];
    }
    cell.textLabel.text = self.str;
    
    return cell;
}

// cell 点击
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}


@end
